package com.ray.service;

import com.ray.config.AppConfig;
import com.ray.pojo.Student;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class StudentServiceImpl
{

    public void getStudentByAnnotation()
    {
        ApplicationContext cpx = new ClassPathXmlApplicationContext("applicationContext.xml");
        Student studentAutowiredByName = cpx.getBean("studentByAnnotation", Student.class);
        System.out.println(studentAutowiredByName.toString());
    }

    public void getStudentByBean()
    {
        ApplicationContext cpx = new AnnotationConfigApplicationContext(AppConfig.class);
        Student studentAutowiredByName = cpx.getBean("userByBean", Student.class);
        System.out.println(studentAutowiredByName.toString());
    }
}
